<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

$link = mysql_connect("localhost", "root", "laropavieja.net.co") or die(mysql_error());
mysql_select_db("pba", $link) or die(mysql_error());


$sql = "SELECT b.nombre,c.call_id,c.codigo,ct.name as ciudad,dp.name as departamento, a.nombres,a.numero_identificacion,a.primer_apellido,a.segundo_apellido FROM beneficiaries a LEFT JOIN  properties b on b.id=a.property_id LEFT JOIN cities ct ON ct.id=b.city_id LEFT JOIN departaments dp on dp.id=ct.departament_id LEFT JOIN proyects c on c.id=b.proyect_id ";

$res = mysql_query($sql, $link) or die(mysql_error());
echo"<table>";
while ($row = mysql_fetch_array($res)) {

   
    mysql_select_db("sitcake", $link) or die(mysql_error());
     $cedIpdr=$row['numero_identificacion'];
    $sql1 = "SELECT rs.fecha,rs.numero,d.codigo,a.nombres,c.nombre as convocatoria,a.documento,a.primer_apellido FROM owners a LEFT JOIN  properties b on b.id=a.property_id LEFT JOIN proyects d on d.id=b.proyect_id LEFT JOIN calls c on c.id=d.call_id LEFT JOIN resolutions rs ON rs.proyect_id=d.id WHERE documento='$cedIpdr' And documento <> '0';";

    $res1 = mysql_query($sql1, $link) or die(mysql_error());
    while ($row1 = mysql_fetch_array($res1)) {
        
            echo "<tr><td>".$row['call_id']."</td><td>".$row['codigo']."</td><td>".$row['nombre']."</td><td>".$row['departamento']."</td><td>".$row['ciudad']."</td><td>".$row['numero_identificacion']."</td><td>".$row['nombres']."</td><td>".$row['primer_apellido']."</td><td>".$row1['codigo']." ".$row1['convocatoria']."</td><td>".$row1['documento']."</td><td>".$row1['nombres']."</td><td>".$row1['primer_apellido']."</td><td>".$row1['numero']."</td><td>".$row1['fecha']."</td></tr>";
            
        
    }
}

echo"<table>";
